<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

	<%@ page import="java.sql.ResultSet" %>
	<%@ page import="java.sql.SQLException" %>
	<%@ page import="java.sql.Statement" %>
	<%@ page import="java.sql.Connection" %>
	<%@ page import="java.sql.DriverManager" %>
	<%@ page language="java" import="java.lang.*" %>
	<%@ page import = "java.sql.SQLException" %>
	<%@ page import = "com.seniorproject.aims.*" %>
	<%@ page import = "java.util.List" %>
	<%@page import="java.util.ArrayList"%>
	<%@ page import = "java.util.Properties" %>
	<%@ page import = "javax.servlet.ServletContext" %>
	<%@ page import = "java.io.File" %>
	<%@ page import = "java.io.InputStream" %>
	
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Search Curriculum</title>
<link rel="stylesheet" type="text/css" href="css/stylev2.css" />
	<link rel="stylesheet" href="css/validation.css" />
	<link rel="stylesheet" href="css/jquery.mobile-1.3.2.min.css"/>
	<link rel="stylesheet" type="text/css" href="css/table-no-header.css" />
	<script type="text/javascript" src="js/livevalidation_standalone.js"></script> 
	<script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
	<link rel="stylesheet" type="text/css" href="css/student-system.css" />
	
	<style type="text/css">
		a {
	      text-decoration:none;
	   }
	</style>
	
<style>

	.silvergrad td {
	    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFF', endColorstr='#CCC');
	    background: -webkit-gradient(linear, left top, left bottom, from(#FFF), to(#CCC));
	    background: -moz-linear-gradient(top, #FFF, #CCC);
	}
	.silvergrad:hover td {
	    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#999', endColorstr='#CCC');
	    background: -webkit-gradient(linear, left top, left bottom, from(#999), to(#CCC));
	    background: -moz-linear-gradient(top, #999, #CCC);
	}
	
	.bluegrad td {
	    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#c9e3fd', endColorstr='#aad4ff');
	    background: -webkit-gradient(linear, left top, left bottom, from(#c9e3fd), to(#aad4ff));
	    background: -moz-linear-gradient(top, #c9e3fd, #aad4ff);
	}
	.bluegrad:hover td {
	    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#85b7eb', endColorstr='#cae1f8');
	    background: -webkit-gradient(linear, left top, left bottom, from(#85b7eb), to(#cae1f8));
	    background: -moz-linear-gradient(top, #85b7eb, #cae1f8);
	}
</style>

<script>
		function deleteButton(id) {
			
			var CurriculumId = (document.getElementById('CurriculumId2' + id)).value;
			var nameCurriculumEN = (document.getElementById('nameCurriculumEN' + id)).innerHTML;			
			var dep = (document.getElementById('departmentName' + id)).innerHTML;
			//var curriId = (document.getElementById('CurriculumId' + id)).innerHTML;
			
			
			if (confirm("คุณต้องการจะลบข้อมูลหลักสูตร" + nameCurriculumEN + "ของภาควิชา " + dep) == true) {
				/* AJAX */
				var xmlhttp;
				
				if(window.XMLHttpRequest) {
					// code for IE7+, Firefox, Chrome, Opera, Safari
					xmlhttp = new XMLHttpRequest();
				}
				else {
					// code for IE6, IE5
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				}
				
				xmlhttp.onreadystatechange = function() {
					if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
						window.location.reload();
						alert("สำเร็จ");////////test///////
					}
				}
				
				xmlhttp.open("POST", "curriculum_delete_curriculum.jsp?CurriculumId="+CurriculumId, true);
				xmlhttp.send();
		    } else {

		    }
			
		}
		
/*$(document).ready(function(){	
	 
		$("#result_div").hide();
	
		$("button").click(function(){
			var select = document.getElementById("department_in");
			var department_in = select.options[select.selectedIndex].value;	
			
			 alert("department:"+department_in);
			 
			 var depart_is_null = 1;//1 = null
			 
			 if(department_in=="select"){
				 alert("กรุณาเลือกภาควิชาก่อนครับ");
				 return false;
	 		 }else{
	 			
	 			 depart_is_null = 0;
	 		 }
			 var sql_con = "";		
			 sql_con =  " AND D.department_id="+department_in+"";
				
				
			 var xmlhttp;
				
				if(window.XMLHttpRequest) {
					// code for IE7+, Firefox, Chrome, Opera, Safari
					xmlhttp = new XMLHttpRequest();
				}
				else {
					// code for IE6, IE5
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				}
			 
				xmlhttp.onreadystatechange = function() {
					if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {	
						alert("I'm Back");//////////////////
						
						if($('#result_div').find('div').length > 0) {					
							$('#result_div').find('div').remove();
						}
						
						var jsonObj = JSON.parse(xmlhttp.responseText);
						
						//alert("I'm Back");
						if(jsonObj.length == 0) {
						//	massage();
							alert("ไม่พบข้อมูล");
						}
						else{
							alert("That work !!!");
							
							
							head = '<div class="CSSTableGenerator">'
									+ '<table align="center" id="table_student">'
									+ '<tr>'																	
									+ '<td><center><strong>ชื่อหลักสูตรภาษาไทย</strong></center></td>'
									+ '<td><center><strong>ชื่อหลักสูตรภาษาอังกฤษ</strong></center></td>'
									+ '<td><center><strong>ภาควิชา</strong></center></td>	'							
									+ '<td><center><strong>ระดับปริญญา</strong></center></td>'
									+ '<td><center><strong>ปีพ.ศ.</strong></center></td>'
									+ '<td><center><strong>พ.ศ.ที่ปรับปรุง</strong></center></td>'
									+ '<td><center><strong>หน่วยกิต</strong></center></td>'
									+ '<td><center><strong>หลักสูตร</strong></center></td>'
									+ '<td>Details&nbsp;</td>'
									+ '<td>Delete&nbsp;</td>'
					              	+ '</tr>';
									
							$('#result_div').append(head);
						
							for(i in jsonObj) {
								if(i%2 == 0) { 
									class_name = 'silvergrad';
								}
								else {
									class_name = 'bluegrad';
								}
								
								text = 
										'<tr class="'+class_name+'" onclick="curriculum_detail(\''+jsonObj[i].studentId+'\')">'							
										+ '<td width="100"><center>'+jsonObj[i].curriculumNameTH+'</center></td>'
										+ '<td width="100"><center>'+jsonObj[i].curriculumNameEN+'</center></td>'
										+ '<td width="100"><center>'+department_in+'</center></td>'
										+ '<td width="100"><center>'+jsonObj[i].degree+'</center></td>'
										+ '<td width="100"><center>'+jsonObj[i].year+'</center></td>'
										+ '<td width="100"><center>'+jsonObj[i].modified+'</center></td>'
										+ '<td width="100"><center>'+jsonObj[i].credit+'</center></td>'
										+ '<td width="100"><center>'+jsonObj[i].program+'</center></td>'
										+ '</tr>';
										
								$('#table_student').append(text);
							}
							
							$('#result_div').append('</table></div>');
						}
						
						
						//System.out.println("temp_x:"+temp_x);	
					
					
					}// end if check state
				}// end function
				
				//xmlhttp.open("POST", "student_search_background.jsp?user_input_search=" + user_search_input+"&option="+option_value, true);
				alert("sql_con:"+sql_con);	
				xmlhttp.open("POST", "curriculum_search_background.jsp?sql_con="+sql_con,true);
				
				xmlhttp.send();
			  
			  $("#result_div").show();
			 
		});
				 
				
});
*//*
function show_student_detail(id){

 	var form = document.createElement("form");
    form.setAttribute("method", "post");
    form.setAttribute("action", "student_detail.jsp");
    var hiddenField = document.createElement("input");
    hiddenField.setAttribute("type", "hidden");
    hiddenField.setAttribute("name", "student_id");
    hiddenField.setAttribute("id","student_id");
    hiddenField.setAttribute("value", id);
    form.appendChild(hiddenField);
    
    document.body.appendChild(form);
    form.submit();
}
*/
///////////////////////////////////////////////////


	</script>



</head>
<body>
<%
//Get session
	String strUser = String.valueOf(session.getAttribute("sUser"));
	HttpSession htp_session = request.getSession();
			
	if (htp_session == null || htp_session.getAttribute("sUser") == null) {
	    // Forward the control to login.jsp if authentication fails or session expires
	    request.getRequestDispatcher("/login.jsp").forward(request,
	        response);
	}	
	
	if("admin".equals(htp_session.getAttribute("sUser"))){%>
	<script>alert("This user dont have PERMISSION to access this zone.");</script>
	<meta HTTP-EQUIV="Refresh" CONTENT="0; URL=admin_home.jsp"> 	
	<%}
	
	//GET PERMISSION

	String name = String.valueOf(session.getAttribute("name"));
	String surname = String.valueOf(session.getAttribute("surname"));
	String role_name = String.valueOf(session.getAttribute("curriculum_role"));
	
	String department_id = String.valueOf(session.getAttribute("department_id"));
			
	System.out.println("name : " + name);///////////////////////////////
	System.out.println("department_id : " + department_id);/////////////////////////
	
	List<String> system_name = new ArrayList<String>();
	
	Permission permission = new Permission(strUser,name);
	permission.setDepartmentId(department_id);
	permission.setCurriculumCreate(Boolean.valueOf(String.valueOf(session.getAttribute("curriculum_create"))));
	permission.setCurriculumDelete(Boolean.valueOf(String.valueOf(session.getAttribute("curriculum_delete"))));
	permission.setCurriculumRead(Boolean.valueOf(String.valueOf(session.getAttribute("curriculum_read"))));
	permission.setCurriculumUpdate(Boolean.valueOf(String.valueOf(session.getAttribute("curriculum_update"))));
	
	String permiss = "";
	if(permission.getCurriculumCreate()) {
		permiss = permiss + "Add";
	}
	if(permission.getCurriculumUpdate()) {
		if("".equals(permiss)) {
			permiss = permiss + "Edit";
		} else {
			permiss = permiss + " Edit";
		}
	}
	if(permission.getCurriculumRead()) {
		if("".equals(permiss)) {
			permiss = permiss + "Read";
		} else {
			permiss = permiss + " Read";
		}
	}
	if(permission.getCurriculumDelete()) {
		if("".equals(permiss)) {
			permiss = permiss + "Delete";
		} else {
			permiss = permiss + " Delete";
		}
	}
	
///////////////////////////////////////////////////////////////////////////////////////////////////////////			
//check permission
	if(!permission.getCurriculumRead()){%>
		<script>alert("This user dont have PERMISSION to access this zone.");</script>
		<meta HTTP-EQUIV="Refresh" CONTENT="0; URL=curriculum_home.jsp"> 	
	<%}

	//set Database Connection
	String hostProps = "";
	String usernameProps  = "";
	String passwordProps  = "";
	String databaseProps = "";

	try {
		//get current path
		ServletContext servletContext = request.getSession().getServletContext();
		
		InputStream input = servletContext.getResourceAsStream("/properties/connectDB.properties");
		Properties props = new Properties();
		
		props.load(input);

		hostProps  = props.getProperty("host");
		usernameProps  = props.getProperty("username");
		passwordProps  = props.getProperty("password");
		databaseProps = props.getProperty("database");
	} catch (Exception e) { 
		out.println(e);  
	}

	System.out.println("hostProperties : "+hostProps);////////////////try/////////////////
	System.out.println("usernameProperties : "+usernameProps);////////////////try/////////////////
	System.out.println("passwordProperties : "+passwordProps);////////////////try/////////////////
	System.out.println("databaseProperties : "+databaseProps);////////////////try/////////////////

	// connect database
			Connection connect = null;		
			try {
				Class.forName("com.mysql.jdbc.Driver");
			
				connect =  DriverManager.getConnection("jdbc:mysql://" + hostProps  + "/" + databaseProps +
						"?user=" + usernameProps  + "&password=" + passwordProps + "&characterEncoding=tis620");//////"&characterEncoding=tis620" Encoding Thai);
			
				if(connect != null){
					System.out.println("Database Connect Sucesses.");
				} else {
					System.out.println("Database Connect Failed.");	
				}
			
			} catch (Exception e) {
				out.println(e.getMessage());
				e.printStackTrace();
			}	
	
	/* find department in database */
	List<Department> department = new ArrayList<Department>();
	
	
	try {			   
		ResultSet rs_department;
		if(("0").equals(permission.getDepartment_id())){
			rs_department  = connect.createStatement().executeQuery("SELECT department_id, department_name_th" 
				+ " FROM department " + " ORDER BY department_id");
		}else{
			
			rs_department = connect.createStatement().executeQuery("SELECT department_id, department_name_th " 
					+ " FROM department " 
				    +" WHERE department_id="+permission.getDepartment_id()
				    );
		}
		
		while(rs_department.next()) {
			Department dep2 = new Department();
			
			dep2.setDepartmentNameTH(rs_department.getString("department_name_th"));
			dep2.setDepartmentId(Integer.parseInt(rs_department.getString("department_id")));
			department.add(dep2);
			
			department.size();
			
			System.out.println("department.size(): "+department.size());
		}
		
	} catch (SQLException e) {
		e.printStackTrace();
	}	

	/*Join curriculum and department*/	
	List<Department> dep = new ArrayList<Department>();
	List<String> CurriculumId = new ArrayList<String>();
	List<String> curriName = new ArrayList<String>();
		try{
			ResultSet rs = connect.createStatement().executeQuery("SELECT C.department_id, C.curriculum_id, C.curriculum_name_th, D.department_name_short, D.department_name_th " 
				+ " FROM curriculum C, department D " 
				+ " WHERE C.department_id = D.department_id "
				+ " ORDER BY C.curriculum_id");
			

			while(rs.next()){
				Department depart = new Department();
				
				curriName.add(rs.getString("curriculum_name_th"));
				CurriculumId.add(rs.getString("curriculum_id"));
				depart.setDepartmentId(Integer.parseInt(rs.getString("department_id")));
				depart.setDepartmentNameShort(rs.getString("department_name_short"));
				depart.setDepartmentNameTH(rs.getString("department_name_th"));
				dep.add(depart);
								
			}
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
%>	
<%	
				/* find Curriculum in database */
				List<Curriculum> curriculum = new ArrayList<Curriculum>();
				try {			   
					ResultSet rs_curriculum = connect.createStatement().executeQuery("SELECT `curriculum_id`, `curriculum_name_th`, `curriculum_name_en`, `bachelor_name_th`, `bachelor_name_en`, `modified`, `department_id`, `credit`, `year`, `co_organizer`, `degree`, `program`, `ohce_approved`, `onec_approved`, `curriculum_EngApp` " 
							+ " FROM curriculum " + " ORDER BY curriculum_id");
					
					while(rs_curriculum.next()) {
						Curriculum cur = new Curriculum();
						
						cur.setCurriculumNameTH(rs_curriculum.getString("curriculum_name_th"));
						cur.setCurriculumNameEN(rs_curriculum.getString("curriculum_name_en"));
						cur.setCurriculumId(Integer.parseInt(rs_curriculum.getString("curriculum_id")));
						cur.setBachelorNameTH(rs_curriculum.getString("bachelor_name_th"));
						cur.setBachelorNameEN(rs_curriculum.getString("bachelor_name_en"));
						cur.setModified(rs_curriculum.getString("modified"));
						cur.setCredit(Integer.parseInt(rs_curriculum.getString("credit")));
						cur.setDepartmentId(Integer.parseInt(rs_curriculum.getString("department_id")));
						cur.setYear(rs_curriculum.getString("year"));
						cur.setCoorganizer(rs_curriculum.getString("co_organizer"));
						cur.setDegree(rs_curriculum.getString("degree"));
						cur.setProgram(rs_curriculum.getString("program"));
						cur.setOHCE(rs_curriculum.getString("ohce_approved"));
						cur.setONEC(rs_curriculum.getString("onec_approved"));
						cur.setEngApp(rs_curriculum.getString("curriculum_EngApp"));
						
						curriculum.add(cur);
					}
					
				} catch (SQLException e) {
					e.printStackTrace();
				}
				
				connect.close();	
%>
	<div id="page-wrap">
		<div id="inside">
			<table border="0">
				<tr style="font-size:24px">
					<td width="600" height="100" style= "background-color: #273b80;border: 0px ;padding: 0px; 0px;" >
						<div id="header_banner-2"></div>
					</td>
					<td width="680" height="100" style= "background-color: #273b80;border: 0px;padding: 0px; 0px;" >
						<p align="right" ><label><font size="4" color="#FFFFFF">  username : <%=strUser %>&nbsp;&nbsp;</font></label></p>
						<a href="logout.jsp"><p align="right"><label style="cursor: pointer;"><font size="3" color="#ffffff">log out &nbsp;</font></label></p></a>
					</td>							
				</tr>
			</table>	
			<table border="0">
				<tr style="font-size:10px">
						<td  width = "720" height="50" style= "background-color:#D0D0D0 ;">
						<center><a href="curriculum_home.jsp"><h2><label style="cursor: pointer;">หน้าหลัก</label></h2></a></center>
						</td>
<%
			if(permission.getCurriculumRead()) {
%>		
						<td  width = "720" height="50" style= "background-color:#FFFFFF ;border-bottom-color: #FFFFFF; border-left-color: #FFFFFF;">
						<center><h2><label>ค้นหา</label></h2></center>
						</td>
<%
			}
			if(permission.getCurriculumCreate()) {
%>		
						<td width = "720" height="50" style= "background-color:#D0D0D0 ;">
							<center><a href="curriculum_import.jsp"><h2><label style="cursor: pointer;">เพิ่มรายวิชา</label></h2></a></center>
						</td>		 
						<td  width = "720" height="50" style= "background-color:#D0D0D0 ;">
						<center><a href="curriculum_add_curriculum.jsp"><h2><label style="cursor: pointer;">เพิ่มหลักสูตรใหม่</label></h2></a></center>
						</td>				
						<td  width = "720" height="50" style= "background-color:#D0D0D0 ;">
						<center><a href="curriculum_modified_home.jsp"><h2><label style="cursor: pointer;">ปรับปรุงหลักสูตร</label></h2></a></center>
						</td>
<%
			}
			if(permission.getCurriculumUpdate()) {
%>
						<td  width = "720" height="50" style= "background-color:#D0D0D0 ;">
						<center><a href="curriculum_edit_home.jsp"><h2><label style="cursor: pointer;">แก้ไขข้อมูลหลักสูตร</label></h2></a></center>
						</td>
<%
			}
%>	
						
				</tr> 
			</table>
			
			
			<div id="main-content-2">	
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								
					<label style="padding-left: 1.0cm;"><font size="5">ค้นหาหลักสูตร</font></label>
					
			</div>
			<div id="main-content-2" style="font-size:15px;padding-left: 1.0cm;">
			
					<form id="formSearch" name="formSearch" method="post" action="">
						<center>		
						  ภาควิชา <select name="department_in" id="department_in">
							  		
							  		
							  		
							  		<%
									for(Department dept : department) {		
										if(dept.getDepartmentId() == 0) {
									%>
											<option value="select">Select</option>
									<% 
										}
										else {
									%>
										<option value="<%=dept.getDepartmentId()%>" id="<%=dept.getDepartmentId()%>"><%=dept.getDepartmentNameTH()%></option>										
									<%		
										}
									}
									%>
							  		
									</select>
							 
							 <br>
							 <br>
							 
							 <input type="submit" value="Search" name="Search" id="Search" style="height: 25px; width: 80px; font-size: medium; ">
							 <br><br>							 
						</center>
					</form>
			</div>		
			
			<%
				String checkButtonSearch = request.getParameter("Search");
				System.out.println("Button "+checkButtonSearch);				
			%>
			
			<div id="main-content-ac">				
					<center>
					<div class="CSSTableGenerator">
						<table border="1">
							  <tr style="font-size:22px">
							   			<td>&nbsp;&nbsp;&nbsp;</td>
										<td><center><strong>ชื่อหลักสูตรภาษาไทย</strong></center></td>
										<td><center><strong>ชื่อหลักสูตรภาษาอังกฤษ</strong></center></td>
										<td><center><strong>ภาควิชา</strong></center></td>											
										<td><center><strong>ระดับปริญญา</strong></center></td>	
										<td><center><strong>ปีพ.ศ.</strong></center></td>
										<td><center><strong>พ.ศ.ที่ปรับปรุง</strong></center></td>
										<td><center><strong>หน่วยกิต</strong></center></td>
										<td><center><strong>หลักสูตร</strong></center></td>										
										<td>Details&nbsp;</td>
										<td>แผนการศึกษา</td>
										<td>Delete&nbsp;</td>
							  </tr>


					<%// TEST EDIT		
					// check Search button is pressed
					if("Search".equals(checkButtonSearch)) {
						int temppo;
						if("select".equals(request.getParameter("department_in"))){		%>					
							<script>alert("กรุณาเลิอกภาควิชาก่อนครับ")</script>
						<%
							temppo = 0;
						}else{
							temppo = Integer.parseInt(request.getParameter("department_in"));	
						}
					//////////////////////////////////////////////////////////////////////////////////////////////////
					int curriculumCount = 1;
			    	int i=0;
			    	for(Curriculum cur : curriculum ) {	
			    		System.out.println("temppo= "+ temppo);
		    			System.out.println("cur.getDepartmentId()= "+ cur.getDepartmentId());
			    		if(temppo == cur.getDepartmentId()){ // IF DEPARTMENT MACTH IN SEARCH = SHOW
			    			System.out.println("Macthed");
				%>
									<tr style="font-size:18px" id="curriculum<%=curriculumCount%>">
										<form id="form<%=curriculumCount%>" name="form<%=curriculumCount%>" method="post" action="curriculum_detail.jsp">
										
												
												<input type="hidden" id="CurriculumId" name="CurriculumId" value="<%=cur.getCurriculumId()%>" />
												<input type="hidden" id="CurriculumId2<%=curriculumCount%>" name="CurriculumId2<%=curriculumCount%>" value="<%=cur.getCurriculumId()%>" /> 
												<%System.out.println(cur.getCurriculumId()); %>
												<td id="curriculumCount" name="curriculumCount" align="center">
													<%=curriculumCount%>
												</td>
												
												<input type="hidden" id="nameCurriculumTH" name="nameCurriculumTH" value="<%=cur.getCurriculumNameTH()%>" /> 
												<td id="nameCurriculumTH<%=curriculumCount%>" name="nameCurriculumTH<%=curriculumCount%>" align="center">
													<%=cur.getCurriculumNameTH()%>
												</td>
												
												<input type="hidden" id="nameCurriculumEN" name="nameCurriculumEN" value="<%=cur.getCurriculumNameEN()%>" /> 
												<td id="nameCurriculumEN<%=curriculumCount%>" name="nameCurriculumEN<%=curriculumCount%>" align="center">
													<%=cur.getCurriculumNameEN()%>
												</td>
												<%System.out.println(cur.getCurriculumNameEN()); %>
												<input type="hidden" id="nameDegreeTH" name="nameDegreeTH" value="<%=cur.getBachelorNameTH()%>" /> 

												
												<input type="hidden" id="departmentId" name="departmentId" value="<%=dep.get(i).getDepartmentId()%>" />
												<input type="hidden" id="departmentName" name="departmentName" value="<%=dep.get(i).getDepartmentNameTH()%>" />
												<td id="departmentName<%=curriculumCount%>" name="department<%=curriculumCount%>" align="center">
													<%=dep.get(i).getDepartmentNameShort()%>
												</td>
												<%
													System.out.println(dep.get(i).getDepartmentNameShort()+"   "+ dep.get(i).getDepartmentId());
												%>
												
												<input type="hidden" id="Degree" name="Degree" value="<%=cur.getDegree()%>" /> 
												<td id="Degree<%=curriculumCount%>" name="Degree<%=curriculumCount%>" align="center">
													<%=cur.getDegree()%>
												</td>
												
												<input type="hidden" id="nameDegreeEN" name="nameDegreeEN" value="<%=cur.getBachelorNameEN()%>" /> 
												<input type="hidden" id="modified" name="modified" value="<%=cur.getModified()%>" /> 
												
												<input type="hidden" id="year" name="year" value="<%=cur.getYear()%>" />
												<td id="year<%=curriculumCount%>" name="year<%=curriculumCount%>" align="center">
													<%=cur.getYear()%>
												</td>
												
												<input type="hidden" id="modified" name="modified" value="<%=cur.getModified()%>" /> 
												
													<%
														if(cur.getModified() == null || cur.getModified().equals("null") || cur.getModified().equals("-")){%>
														<td id="modified<%=curriculumCount%>" name="modified<%=curriculumCount%>" align="center">
															<center><%="-"%></center>
														</td>
														<%}else{%>
														
														<td id="modified<%=curriculumCount%>" name="modified<%=curriculumCount%>" align="center">
															<%=cur.getModified()%>
														</td>
													<%}%>
												
												<input type="hidden" id="credit" name="credit" value="<%=cur.getCredit()%>" /> 
												<td id="credit<%=curriculumCount%>" name="credit<%=curriculumCount%>" align="center">
													<%=cur.getCredit()%>
												</td>
																					
												
												<input type="hidden" id="Coorganizer" name="Coorganizer" value="<%=cur.getCoorganizer()%>" /> 
												
													
												<input type="hidden" id="Program" name="Program" value="<%=cur.getProgram()%>" /> 
												<td id="Program<%=curriculumCount%>" name="Program<%=curriculumCount%>" align="center">
													<%=cur.getProgram()%>
												</td>	
												
												<input type="hidden" id="OHCE" name="OHCE" value="<%=cur.getOHCE()%>" /> 
												<input type="hidden" id="ONEC" name="ONEC" value="<%=cur.getONEC()%>" />
												<input type="hidden" id="EngApp" name="EngApp" value="<%=cur.getEngApp()%>" /> 
												<input type="hidden" id="delete" name="delete" value="none" />		
														
												<td><input type="submit" value="Info" style="cursor: pointer;" name="details" class="buttonStyle"></td>		
																						
											</form>
											
											<!-- FORM FOR SCHEDULE -->
											<form id="form<%=curriculumCount%>" name="form<%=curriculumCount%>" method="post" action="curriculum_add_schedule.jsp">
												
												<input type="hidden" id="CurriculumId" name="CurriculumId" value="<%=cur.getCurriculumId()%>" />
												<input type="hidden" id="nameCurriculumEN" name="nameCurriculumEN" value="<%=cur.getCurriculumNameEN()%>" /> 
												<input type="hidden" id="departmentId" name="departmentId" value="<%=dep.get(i).getDepartmentId()%>" />
												<input type="hidden" id="year" name="year" value="<%=cur.getYear()%>" />
												<input type="hidden" id="departmentName" name="departmentName" value="<%=dep.get(i).getDepartmentNameTH()%>" />
												<input type="hidden" id="credit" name="credit" value="<%=cur.getCredit()%>" /> 
												
												<input type="hidden" id="YearSemester" name="YearSemester" value="0" /> 
												<input type="hidden" id="TermSemester" name="TermSemester" value="0" /> 
												<input type="hidden" id="CreditSemester" name="CreditSemester" value="0" />
												
												<input type="hidden" id="checker" name="checker" value="none" />	
												<input type="hidden" id="delete" name="delete" value="none" />	
												<input type="hidden" id="sysID" name="sysID" value="none" />	
												<td>
													<center><span title="เพิ่มข้อมูล">
														<input type="image" src="image/add_icon.png" style="cursor: pointer;" height="30px" width="30px" name="schedule" align="middle">
													</span></center>
												</td>
											</form>
								<%
									if(permission.getCurriculumDelete()){
								%>				
											<td>
												<center><span title="ลบข้อมูล">
													<img src="image/delete_icon.png" height="30px" width="30px" style="cursor: pointer;"  onclick="deleteButton('<%=curriculumCount%>')" /></img>
												</span></center>
											</td>
										
								<%
									}else{
								%>
										 	<td><center>-</center></td>
								<%	}
								%>	
									</tr>
									
					<%}else{
							System.out.println("Not Macthed");
						}
			    		
			    		i++;
						curriculumCount++;
			    	}
					}//Search Button
				%>
						
						</table>
						<div id="result_div"></div>
					</div>
					</center>
					
					
					
				<div style="clear: both;"></div>
				
			<div id="footer"></div>
			
		</div>		
			<div style="clear: both;"></div>		
   </div>
   </div>
</body>
</html>